package org.broadway.jmx;

import org.broadway.monitor.Monitor;

/**
 * This is the MBean management interface for the JmxMonitor.
 * It is is designed to observe changes in attributes of MBeans
 * that are deployed in an MBean server.  
 * The service uses a string literal to express the condition for which 
 * to monitor.  When the condition is evaluated to true, it fires a notification
 * to be handled by an Action component (also running in the MBean server context).
 *  
 * @author vladimir vivien
 *
 */
public interface JmxMonitorMBean extends BaseJmxBean{
        /***
         * Sets an instance of the Monitor object used by the bean.
         * @param monitor
         */
	public void setMonitor(Monitor monitor);

	/***
         * Adds an MBean to be observed by the monitor.
         * @param alias - a short name to reference the bean
         * @param jmxName - the JMX object name for the 
         */
	public void addObservedMBean(String alias, String jmxName);
        /***
         * Removes a registered MBean component being monitored.
         * @param alias - the alias 
         */
	public void removeObservedMBean(String alias);
	
	/***
         * The expression used when monitoring MBean values.
         * @param exp - A string expression representing condition to monditor.
         */
	public void setMonitorExpression(String exp);
        /***
         * Getter that retunrs the monitor exression.
         * @return
         */
	public String getMonitorExpression();

	/***
         * This is the JMX ObjectName of a Timer service installed in the MBean server.
         * The Monitor object will listen to Notification Type = broadway.timer.signal
         * @param jmxName - ObjectName of an MBean Timer service component.
         */
	public void setTimerServiceName(String jmxName);
        /***
         * Getter that returns ObjectName of Timer service component
         * @return
         */
	public String getTimerServiceName();

	// life cycle / info
        /***
         * Controller method that starts the JmxMonitor component.
         */
	public void start();
        /***
         * Controller method that stops the JmxMonitor component.
         */
	public void stop();
        /***
         * Reporsts the status of the component.
         * @return
         */
	public boolean isStarted();
        /***
         * Returns date the component was created.
         * @return Returns creation date or UNKNOWN
         */
	public String getDateCreated();
        /***
         * Returns the date component was last started.
         * @return date component was started or UNKNOWN
         */
	public String getDateStarted();
        /***
         * Returns date component was last stopped
         * @return returns date last stopped or UKNOWN
         */
	public String getDateStopped();
	
        /***
         * This sets a flag to indicate when JmxMonitor should send an Action Notification.
         * This valued will be based on the result of the Monitor Expression.
         * @param flag - true = notification sent when result is true, false = notification is sent when 
         * expression is evaluated to false.
         */
        public void setSendActionNotificationWhen(boolean flag);
        /***
         * Returns notification flag value.
         * @return
         */
        public boolean getSendActionNotificationWhen();
        
        /***
         * Returns the number of time the JmxMonitor component scans the observed object.
         * @return
         */
	public long getScanCount();
}
